package com.sq.partner.manager.dao.impl;

import com.sq.partner.manager.dao.ZfbInfoDao;
import com.sq.partner.manager.mybatis.model.ZfbBillInfoVo;
import com.sq.partner.manager.util.Page;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.List;
import java.util.Map;

@Repository
public class ZfbInfoDaoImpl extends BaseDaoImpl implements ZfbInfoDao {
    @Override
    public Page queryZfbBillInfoPage(Page page) throws Exception {
        Map<String,Object> map = (Map<String, Object>) page.getType();
        page.setTotal((Integer)this.query("queryZfbCountByMap", map));
        List<ZfbBillInfoVo> list = queryList("queryzfbbill", map);
        page.setData(list);
        return page;
    }

    @Override
    public List<Map<String, Object>> queryZfbBillInfoList(Map<String, Object> map) throws Exception {
        List<Map<String, Object>> list = queryList("queryZfbBillInfoList", map);
        for (Map<String, Object> m : list) {
            String deptName = queryDeptNameByCode((String) m.get("DEPTCODE"));
            m.put("DEPTNAME",deptName);
        }
        return list;
    }

    @Override
    public Page queryZfbRefundInfoPage(Page page) throws Exception {
        Map<String,Object> map = (Map<String, Object>) page.getType();
        page.setTotal((Integer)this.query("queryZfbRefoundCountByMap", map));
        List<ZfbBillInfoVo> list = queryList("queryzfbRefundInfo", map);
        page.setData(list);
        return page;
    }

    @Override
    public List<Map<String, Object>> queryZfbRefundInfoList(Map<String, Object> map) throws Exception {
        List<Map<String, Object>> list = queryList("queryZfbRefundInfoList", map);
        for (Map<String, Object> m : list) {
            String deptName = queryDeptNameByCode((String) m.get("DEPTCODE"));
            m.put("DEPTNAME",deptName);
        }
        return list;
    }

    @Override
    public String queryDeptNameByCode(String deptCode) throws Exception {
        return (String)this.query("queryDeptNameByCode",deptCode) ;
    }
}
